import numpy as np
import matplotlib.pyplot as plt
import os
import matplotlib
matplotlib.rcParams['pdf.fonttype']=42
matplotlib.rcParams['ps.fonttype']=42

x = np.arange(5)
dis = [0.1388, 0.1082, 0.0248, 0.1494, 0.0086]
pre = [0.0958, 0.0920, 0.0785, 0.0949, 0.0755]
mae = [0.0646, 0.0315, 0.0326, 0.0462, 0.0287]

total_width, n = 0.6, 3
width = total_width / n
x = x - (total_width - width) / 2
plt.figure(figsize=(7.6, 4.5))
plt.bar(x, dis,  width=width, label='AUC')
plt.bar(x + width+0.05, pre, width=width, label='MSE')
plt.bar(x + 2 * width+0.1, mae, width=width, label='MAE')
plt.xticks([0,1,2,3,4],['LVF', 'Mean', 'KNN', 'MF', 'GEDA'], fontfamily='Times New Roman', fontsize=15)
plt.yticks(fontsize=15, fontproperties='Times New Roman')
plt.legend(loc='upper right', prop={'family': 'Times New Roman', 'size': '12'})

plt.text(x[4]-0.12, dis[4], dis[4], ha='center', va='bottom', fontsize=11, fontfamily='Times New Roman')
plt.text(x[4] + width + 0.05, pre[4], pre[4], ha='center', va='bottom', fontfamily='Times New Roman')
plt.text(x[4]+0.08 + 2*width + 0.12, mae[4], mae[4], ha='center', va='bottom', fontfamily='Times New Roman')

# plt.subplots_adjust(bottom=0.2, left=0.05, right=0.98, top=0.98)

plt.tight_layout()
# plt.show()
plt.savefig(os.path.join('figure', 'bijiao' + ".pdf"), format='pdf', dpi=600)
